package com.sure.supermarketserver.branch.staff.dao;

import com.sure.supermarketserver.branch.staff.StaffDto;
import com.sure.supermarketserver.branch.staff.Staff;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StaffDao {
    @Select("select count(br_id) from staff where st_id = #{userId}")
    int checkByUserId(String userId);

    //查询员工信息
    List<Staff> findStaffList(StaffDto dto, @Param("userId") String userId);

    List<Staff> findAllStaffList(StaffDto dto);

    @Insert("insert into staff (br_id ,st_id,st_pwd) select br_id,'staff','111' from staff where st_id=#{Id}")
    void insertStaff(String Id);

    @Update("update staff set st_id =#{st_id}, st_name =#{st_name}, st_sex =#{st_sex}, st_birth =#{st_birth}, st_tel =#{st_tel}, st_address =#{st_address}, st_state =#{st_state}, st_remark =#{st_remark}, st_salary=#{st_salary}, st_entry=#{st_entry} where st_id='staff'")
    void updateStaff(StaffDto dto);

    @Insert("insert into staff_role(st_id,ro_id) values(#{st_id},#{ro_id})")
    void insertRole(StaffDto dto);

    @Delete("delete from staff where st_id=#{id}")
    void delStaff(String id);

    @Delete("delete from staff_role where st_id=#{id}")
    void delRole(String id);

    @Update("update staff set st_name =#{st_name}, st_id =#{st_id}, st_sex =#{st_sex}, st_birth =#{st_birth}, st_tel =#{st_tel}, st_address =#{st_address}, st_state =#{st_state},  st_remark =#{st_remark}, st_salary=#{st_salary} where st_id=#{st_id}")
    void updStaff(StaffDto dto);

    @Update("update staff_role set ro_id=#{ro_id} where st_id=#{st_id}")
    void updRole(StaffDto dto);

    @Select("select count(0) from staff where st_id = #{st_id}")
    boolean findStaff(String st_id);
}
